/**
 * 
 */
package edu.gatech.oad.mule.view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JLabel;
import javax.swing.JPanel;

import edu.gatech.oad.mule.view.interfaces.RenderableGameDriver;
import edu.gatech.oad.mule.view.interfaces.RenderableMap;
import edu.gatech.oad.mule.view.interfaces.RenderablePlayer;
import edu.gatech.oad.mule.view.interfaces.RenderableWorldMap;
import edu.gatech.oad.mule.view.interfaces.RenderableMap.MapType;

/**
 * Represents the view that is displayed to the user during the development phase of the game.
 * @author Dale Avery
 *
 */
class DevelopmentPanel extends JPanel {
	
	private class TimerPanel extends JPanel {
		
		private RenderableGameDriver driver;
		private JLabel label;
		
		public TimerPanel(RenderableGameDriver driver) {
			this.driver = driver;
			label = new JLabel();
			this.add(label);
		}
		
		@Override
		public void paintComponent(Graphics g) {
			// Let UI Delegate paint first, which
			// includes background filling since
			// this component is opaque.

			super.paintComponent(g);
			label.setText("Remaining Time: " + (driver.getRemainingTime() / 1000) + " seconds.");
		}
	}

	RenderableGameDriver driver;
	
	/**
	 * Constructs a new DevelopmentPanel with the given game data.
	 * @param dimension The desired dimensions of the panel.
	 * @param driver The GameDriver from which game data will be obtained.
	 */
	public DevelopmentPanel(Dimension dimension, RenderableGameDriver driver) {
		this.driver = driver;
		
		// Player panels should be displayed on the bottom of the panel
		this.setLayout(new BorderLayout());
		Dimension infoDim = new Dimension();
		infoDim.setSize(dimension.width, dimension.height/5);
		
		// Place a timer panel in the top of the panel
		add(new TimerPanel(driver), BorderLayout.NORTH);

		// Place the info panel in the bottom of the panel.
		PlayerInfoPanel info = new PlayerInfoPanel(driver.getAllPlayers(), infoDim);
		this.add(info, BorderLayout.SOUTH);
		
		MapPanel map = new MapPanel(dimension, driver);
		map.setPreferredSize(new Dimension(dimension.width, dimension.height * 4 / 5));
		this.add(map, BorderLayout.CENTER);
	}
}
